package com.skzh.web.controller.unflyzone;

import com.skzh.common.annotation.Log;
import com.skzh.common.core.controller.BaseController;
import com.skzh.common.core.domain.AjaxResult;
import com.skzh.common.core.page.TableDataInfo;
import com.skzh.common.enums.BusinessType;
import com.skzh.unflyzone.domain.HxUnfly;
import com.skzh.unflyzone.service.IHxUnflyService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @Author zr
 * @Description 环形禁飞区控制器
 * @Date 2025/3/26 9:45
 */
@RequestMapping("/hxunflyzone/hxInfo")
@RestController
public class HxController extends BaseController {

    @Autowired
    private IHxUnflyService hxUnflyService;

    /**
     * 新增环形禁飞区
     */
    @ApiOperation(value = "新增环形禁飞区")
    @Log(title = "环形禁飞区", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody HxUnfly hxUnfly) {
        return toAjax(hxUnflyService.insertHxUnfly(hxUnfly));
    }


    /**
     * 查询环形禁飞区
     */
    @ApiOperation(value = "查询环形禁飞区")
    @GetMapping("/list")
    public TableDataInfo list(HxUnfly hxUnfly) {
        if (hxUnfly != null) {
            List<HxUnfly> list = hxUnflyService.selectHxList(hxUnfly);
            return getDataTable(list);
        }
        return null;
    }

    /**
     * 根据ID删除环形禁飞区
     * */
    @ApiOperation(value = "根据ID删除环形禁飞区")
    @Log(title = "环形禁飞区", businessType = BusinessType.DELETE)
    @DeleteMapping("/{id}")
    public AjaxResult delete(@PathVariable Long id) {
        return toAjax(hxUnflyService.deleteHxUnflyById(id));
    }

}
